#ifndef __SCAN_H
#define __SCAN_H

#include "stm32f10x.h"                  // Device header
#include "usart.h"
#include "delay.h"

#define SCAN_CMD00_ADDR 0x00
#define SCAN_CMD05_ADDR 0x05
#define SCAN_CMD06_ADDR 0x06
#define SCAN_CMD0D_ADDR 0x0d
#define SCAN_CMD0F_ADDR 0x0f
#define SCAN_CMD10_ADDR 0x10
#define SCAN_CMD60_ADDR 0x60

#define SCAN_CMD00  ((uint16_t)SCAN_CMD00_ADDR << 8) | 0xf7
#define SCAN_CMD05  ((uint16_t)SCAN_CMD05_ADDR << 8) | 0x02
#define SCAN_CMD06  ((uint16_t)SCAN_CMD06_ADDR << 8) | 0x14
#define SCAN_CMD0D  ((uint16_t)SCAN_CMD0D_ADDR << 8) | 0xa2
#define SCAN_CMD0F  ((uint16_t)SCAN_CMD0F_ADDR << 8) | 0x32
#define SCAN_CMD10  ((uint16_t)SCAN_CMD10_ADDR << 8) | 0x0a
#define SCAN_CMD60  ((uint16_t)SCAN_CMD60_ADDR << 8) | 0x00

#define SCAN_MUTE_BIT           6
#define SCAN_LOCATOR_LIGHT_BIT  0x30
#define SCAN_FILL_LIGHT_BIT     0x0c

typedef struct
{
    uint16_t cmd00; //常用设置
    uint16_t cmd05; //读取间隔 100ms
    uint16_t cmd06; //单次读取时长 100ms
    uint16_t cmd0d; //输出模式 串口或USB
    uint16_t cmd0f; //灵敏度1
    uint16_t cmd10; //灵敏度2
    uint16_t cmd60; //后缀
} scanner_cmd_t;    //扫描器设置 高八位为地址，低八位为数据

uint8_t SCAN_FactoryReset(void);
uint8_t SCAN_WriteCmd(uint8_t addr, uint8_t data);
uint8_t SCAN_ReadCmd(uint8_t addr);
uint8_t SCAN_SaveCmd(void);
//void SCAN_Init(void);

#endif
